<?php

	require_once("fta.201003310000/fta.php");
	fta_registerModules(
		array(
		"cms.201003310000/config/cmsConfig",//we will deprecate the old cms config soon..
		"site/components/MAIExhibition",
		"FTAFormMailer/ftaFormMailer",
	));	
	
	$exhibitionId = extractStringWithKeyFromArray("productId", $_REQUEST, null);
	
	//echo "class = $class";
	if(!is_null($exhibitionId)){
		$o = mai_getSharedExhibitionObject();
		$exhibition = $o->getExhibition($exhibitionId);
		$_POST['exhibition'] = $exhibition->title;
	}
	
	//echo "class = <pre>";print_r($exhibition); echo "</pre>";
	
	if(isset($_POST['member'])){
		$_POST['member'] = 'true';//echo "post = " . $_POST['member'];
	} else {
		$_POST['member'] = 'false';
	}
	
	
	
	
	
	
	
	
	$authInfo = setupPublicUser();
					
	//ie cluster fuck 
	$submit_x = extractBooleanWithKeyFromArray('enrol-button_x',$_POST,false);
	$submit_y = extractBooleanWithKeyFromArray('enrol-button_y',$_POST,false);
	$submit = ($submit_x || $submit_y);
	$submit = extractBooleanWithKeyFromArray('enrol-button',$_POST,$submit);
	
	$formDescriptor = fta_getFormMailerFormDescriptor(2343,$db);
	
	
	
	$formSent = false;
	if ( $submit ) {
		$invalidFields = array();
		//$recipients = array();		
		//$formSent = fta_formMailerSendForm($formDescriptor,$_POST,$recipients, $authInfo, $invalidFields, $db );
		//echo "formSent = <pre>";print_r($formSent);echo "</pre>";
		//echo "invalidFields = <pre>";print_r($invalidFields);echo "</pre><br /><br />";
		
		// validate the form..
			$extractedFormData = fta_formMailerValidateFormData($formDescriptor, $_POST,$invalidFields);
			//echo "invalidFields = <pre>";print_r($invalidFields);echo "</pre><br /><br />";

		/*$toAddress = extractEmailWithKeyFromArray('email',$_REQUEST ,null);
		if ($formSent && !is_null($toAddress) && $formDescriptor->sendThankYouEmail){

			fta_formMailerSendThankYouEmail(
				array(
				$toAddress	
				),$formDescriptor
			);
		}*/		
		
		if (count($invalidFields) == 0 ){
		//	header("Location: /Cart/");
		//	echo "Form Sent";
		
		//Save data to session
			$_POST['formMailerId'] = "2343";
			
			$formMailerDataForOrderItem = serialize($_POST);
			
			
			//$formDataForCart[2343][] = $_POST;
			//$_POST['submitedFormDataForCart'] = $formDataForCart[2343];
			
			
			
			$_POST['formMailerDataForOrderItem'] = $formMailerDataForOrderItem;
			
			
			//echo "Post = <pre>";print_r($_POST);echo "</pre><br /><br />";
			include_once("../html/cart.php");
			exit();die();
		}
	}
	
	
	
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta name="Keywords" content="<?php echo $metadataKeywords; ?>" />
<meta name="Description" content="<?php echo $metadataDescription; ?>" />

<title><?php echo $pageTitle; ?> | Mairangi Arts Centre</title>

<?php include ("includes/external-files.php"); ?>
<script src="/js/jquery.inlined-forms.js" type="text/javascript"></script> 

<?php include ("includes/analytics.php"); ?>   
</head>

<body id="exhibitions" class="entry-forms">



<?php include ("includes/head.php"); ?>





<div id="container">


		<div id="supplementary-content">
                <h2>Get the form!</h2>
                If you have any questions or require any assistance, please <a href="/Contact-Us/">contact us.</a>
                <br />
				<br />
				<a class="link-pdf" href="/html/blob.php?attach=true&documentCode=2775" title="Click here to download...">Download PDF &gt;</a>
				
				<br /><br />
				
				<h2>Terms</h2>
				<?php echo $pageContent; ?>
				
		</div><!-- supplementary-content ends -->


	<div id="content">

        <h1><?php echo $pageHeading; ?></h1>
        
        <div id="content-blocks">
        
        
            
            
         
		   <form id="exhibition-enrol-form" method="post" action="<?= $_SERVER['REQUEST_URI'] ?>" enctype="multipart/form-data">
		   		<?php /* <input type="hidden" name="exhibition" id="exhibition" value="<?php echo $exhibition->title; ?>" /> */ ?>
		        <input type="hidden" name="returnUrl" value="/Exhibitions/Entry-Forms/" />
		        <input type="hidden" name="orderStep" value="orderItem" /> 
		        <input type="hidden" name="quantity" value="1" />
		        
		        <div>
		        <label>Enrol me in:</label>
		        <select <?php echo fta_getFormMailerInputIdAndValue('productId', $_REQUEST, $formDescriptor); ?> class="input-text" >
		        	<option value="">Select Your Exhibition:</option>
		        	<?php echo mai_getExhibitionEnrolmentOptions($_POST['productId']); ?>
		        	
		        </select>
		        <?php echo fta_getFormMailerValidationMessageForField('productId', $invalidFields, $formDescriptor); ?>
		        </div>
		        
		        <div>
		        <input type="checkbox" <?php echo fta_getFormMailerInputIdAndValue('member',$_REQUEST, $formDescriptor); if($_POST['member'] == "true"){ echo "checked"; } ?> /> <label style="display: inline;">Are you a Member? (please tick if applicable to receive your membership discount)</label>
		        <?php echo fta_getFormMailerValidationMessageForField('member', $invalidFields, $formDescriptor); ?>
		        </div>
		        
		        <div>
		        <?php 
		        	$inputValue = '';
		        	$inputValues = '';
		        	ob_start();
		        	fta_getFormMailerInputIdAndValue('memberNo',$_REQUEST, $formDescriptor);
		        	$inputValue = ob_get_clean();
		        	$inputValues = explode(" ", $inputValue);
		        ?>
		        <label for="memberNo" class="inlinedtrim($inputValues[2]) != 'value=""'">Membership No. (please enter if applicable to receive your discount)</label>
		        <input class="input-text" type="text" <?php echo fta_getFormMailerInputIdAndValue('memberNo',$_REQUEST, $formDescriptor); ?> />
		        <?php echo fta_getFormMailerValidationMessageForField('memberNo', $invalidFields, $formDescriptor); ?>
		        </div>
		        
		        <div>
		        <?php 
		        	$inputValue = '';
		        	$inputValues = '';
		        	ob_start();
		        	fta_getFormMailerInputIdAndValue('firstName',$_REQUEST, $formDescriptor);
		        	$inputValue = ob_get_clean();
		        	$inputValues = explode(" ", $inputValue);
		        ?>
                    <label for="firstName" class="inlinedtrim($inputValues[2]) != 'value=""'">First Name:</label>
                    <input class="input-text" <?php echo fta_getFormMailerInputIdAndValue('firstName',$_REQUEST, $formDescriptor); ?> />
                    <?php echo fta_getFormMailerValidationMessageForField('firstName', $invalidFields, $formDescriptor); ?>
				</div>
		        
		        <div>
		        <?php 
		        	$inputValue = '';
		        	$inputValues = '';
		        	ob_start();
		        	fta_getFormMailerInputIdAndValue('lastName',$_REQUEST, $formDescriptor);
		        	$inputValue = ob_get_clean();
		        	$inputValues = explode(" ", $inputValue);
		        ?>
                    <label for="lastName" class="inlinedtrim($inputValues[2]) != 'value=""'">Last Name:</label>
                    <input class="input-text" <?php echo fta_getFormMailerInputIdAndValue('lastName',$_REQUEST, $formDescriptor); ?> />
                    <?php echo fta_getFormMailerValidationMessageForField('lastName', $invalidFields, $formDescriptor); ?>
				</div>
				
				<div>
		        <?php 
		        	$inputValue = '';
		        	$inputValues = '';
		        	ob_start();
		        	fta_getFormMailerInputIdAndValue('email',$_REQUEST, $formDescriptor);
		        	$inputValue = ob_get_clean();
		        	$inputValues = explode(" ", $inputValue);
		        ?>
                    <label for="email" class="inlinedtrim($inputValues[2]) != 'value=""'">Email:</label>
                    <input class="input-text" <?php echo fta_getFormMailerInputIdAndValue('email',$_REQUEST, $formDescriptor); ?>/>
                    <?= fta_getFormMailerValidationMessageForField('email', $invalidFields, $formDescriptor); ?>
				</div>
		        
				<div>
		        <?php 
		        	$inputValue = '';
		        	$inputValues = '';
		        	ob_start();
		        	fta_getFormMailerInputIdAndValue('phone',$_REQUEST, $formDescriptor);
		        	$inputValue = ob_get_clean();
		        	$inputValues = explode(" ", $inputValue);
		        ?>
                    <label for="phone" class="inlinedtrim($inputValues[2]) != 'value=""'">Phone:()</label>
                    <input class="input-text" <?= fta_getFormMailerInputIdAndValue('phone',$_REQUEST, $formDescriptor); ?>/>
                    <?= fta_getFormMailerValidationMessageForField('phone', $invalidFields, $formDescriptor); ?>
				</div>
				
				<div>
		        <?php 
		        	$inputValue = '';
		        	$inputValues = '';
		        	ob_start();
		        	fta_getFormMailerInputIdAndValue('mobile',$_REQUEST, $formDescriptor);
		        	$inputValue = ob_get_clean();
		        	$inputValues = explode(" ", $inputValue);
		        ?>
                    <label for="mobile" class="inlinedtrim($inputValues[2]) != 'value=""'">Mobile:()</label>
                    <input class="input-text" <?= fta_getFormMailerInputIdAndValue('mobile',$_REQUEST, $formDescriptor); ?>/>
                    <?= fta_getFormMailerValidationMessageForField('mobile', $invalidFields, $formDescriptor); ?>
				</div>
		        
				<div>
		        <?php 
		        	$inputValue = '';
		        	$inputValues = '';
		        	ob_start();
		        	fta_getFormMailerInputIdAndValue('street',$_REQUEST, $formDescriptor);
		        	$inputValue = ob_get_clean();
		        	$inputValues = explode(" ", $inputValue);
		        ?>
                    <label for="street" class="inlinedtrim($inputValues[2]) != 'value=""'">Address Line 1:</label>
                    <input class="input-text" <?= fta_getFormMailerInputIdAndValue('street',$_REQUEST, $formDescriptor); ?>/>
                    <?= fta_getFormMailerValidationMessageForField('street', $invalidFields, $formDescriptor); ?>
				</div>
		        
				<div>
		        <?php 
		        	$inputValue = '';
		        	$inputValues = '';
		        	ob_start();
		        	fta_getFormMailerInputIdAndValue('suburb',$_REQUEST, $formDescriptor);
		        	$inputValue = ob_get_clean();
		        	$inputValues = explode(" ", $inputValue);
		        ?>
                    <label for="suburb" class="inlinedtrim($inputValues[2]) != 'value=""'">Address Line 2:</label>
                    <input class="input-text" <?= fta_getFormMailerInputIdAndValue('suburb',$_REQUEST, $formDescriptor); ?>/>
                    <?= fta_getFormMailerValidationMessageForField('suburb', $invalidFields, $formDescriptor); ?>
				</div>
		        
				<div>
		        <?php 
		        	$inputValue = '';
		        	$inputValues = '';
		        	ob_start();
		        	fta_getFormMailerInputIdAndValue('city',$_REQUEST, $formDescriptor);
		        	$inputValue = ob_get_clean();
		        	$inputValues = explode(" ", $inputValue);
		        ?>
                    <label for="city" class="inlinedtrim($inputValues[2]) != 'value=""'">Town/City:</label>
                    <input class="input-text" <?= fta_getFormMailerInputIdAndValue('city',$_REQUEST, $formDescriptor); ?>/>
                    <?= fta_getFormMailerValidationMessageForField('city', $invalidFields, $formDescriptor); ?>
				</div>
				
				<div>
		        <?php 
		        	$inputValue = '';
		        	$inputValues = '';
		        	ob_start();
		        	fta_getFormMailerInputIdAndValue('artistName',$_REQUEST, $formDescriptor);
		        	$inputValue = ob_get_clean();
		        	$inputValues = explode(" ", $inputValue);
		        ?>
                    <label for="artistName" class="inlinedtrim($inputValues[2]) != 'value=""'">Artist Name:</label>
                    <input class="input-text" <?= fta_getFormMailerInputIdAndValue('artistName',$_REQUEST, $formDescriptor); ?>/>
                    <?= fta_getFormMailerValidationMessageForField('artistName', $invalidFields, $formDescriptor); ?>
				</div>
				
				<div>
		        <?php 
		        	$inputValue = '';
		        	$inputValues = '';
		        	ob_start();
		        	fta_getFormMailerInputIdAndValue('titleOfArtwork',$_REQUEST, $formDescriptor);
		        	$inputValue = ob_get_clean();
		        	$inputValues = explode(" ", $inputValue);
		        ?>
                    <label for="titleOfArtwork" class="inlinedtrim($inputValues[2]) != 'value=""'">Title of Artwork:</label>
                    <input class="input-text" <?= fta_getFormMailerInputIdAndValue('titleOfArtwork',$_REQUEST, $formDescriptor); ?>/>
                    <?= fta_getFormMailerValidationMessageForField('titleOfArtwork', $invalidFields, $formDescriptor); ?>
				</div>
				
				<div>
		        <?php 
		        	$inputValue = '';
		        	$inputValues = '';
		        	ob_start();
		        	fta_getFormMailerInputIdAndValue('artworkPrice',$_REQUEST, $formDescriptor);
		        	$inputValue = ob_get_clean();
		        	$inputValues = explode(" ", $inputValue);
		        ?>
                    <label for="artworkPrice" class="inlinedtrim($inputValues[2]) != 'value=""'">Artwork Price:</label>
                    <input class="input-text" <?= fta_getFormMailerInputIdAndValue('artworkPrice',$_REQUEST, $formDescriptor); ?>/>
                    <?= fta_getFormMailerValidationMessageForField('artworkPrice', $invalidFields, $formDescriptor); ?>
				</div>
				
				<div>
		        <?php 
		        	$inputValue = '';
		        	$inputValues = '';
		        	ob_start();
		        	fta_getFormMailerInputIdAndValue('medium',$_REQUEST, $formDescriptor);
		        	$inputValue = ob_get_clean();
		        	$inputValues = explode(" ", $inputValue);
		        ?>
                    <label for="medium" class="inlinedtrim($inputValues[2]) != 'value=""'">Medium:</label>
                    <input class="input-text" <?= fta_getFormMailerInputIdAndValue('medium',$_REQUEST, $formDescriptor); ?>/>
                    <?= fta_getFormMailerValidationMessageForField('medium', $invalidFields, $formDescriptor); ?>
				</div>
				
		        
		        
		        <input id="enrol-button" class="button" name="enrol-button" type="submit" value='1'>
		    </form> 

		</div><!-- Content-blocks ends -->
        
    	
    	

         
   </div><!-- Content ends -->


    
    
	<div id="sub-nav">
    	<ul id="sub-nav-list">
        	<li><h3><a href="/Exhibitions/Currently-Showing/" title="">Currently Showing</a></h3></li>
        	<li><h3><a href="/Exhibitions/Coming-Exhibitions/" title="">Coming Exhibitions</a></h3></li>
        	<li><h3><a href="/Exhibitions/Past-Exhibitions/" title="">Past Exhibitions</a></h3></li>
        	<li class="selected"><h3><a href="/Exhibitions/Entry-Forms/" title="">Entry Forms</a></h3></li>
        </ul>
    </div><!-- Sub-nav ends -->



    
</div><!-- Container ends -->




<?php include ("includes/foot.php"); ?>





</body>

</html>